package com.mazegame;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import com.mazegame.utils.DBUtils;

public class Main {
    public static void main(String[] args) {
        // 获取数据库连接
        try (Connection conn = DBUtils.getConnection()) {
            System.out.println("数据库连接成功！");
            // 查询 users 表
            Statement stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery("SELECT * FROM users");
            // 打印查询结果
            while (rs.next()) {
                System.out.println("用户ID: " + rs.getInt("id") +
                        ", 用户名: " + rs.getString("username") +
                        ", 密码: " + rs.getString("password") +
                        ", 分数: " + rs.getInt("score"));
            }
        } catch (SQLException e) {
            System.out.println("数据库连接失败！");
            e.printStackTrace();
        }
    }
}